<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Symbol内置属性</title>
  </head>
  <body>
    <script>
      // 1. Symbol.hasInstance
      class Person {
        // 当其他对象使用instanceof时会自动调用
        static [Symbol.hasInstance](param) {
          console.log(param);
          console.log("我被用来用于检测类型");
        }
      }
      let o = {};
      console.log(o instanceof Person);

      // 2.Symbol.isConcatSpreadable
      const arr = [1, 2, 3];
      const arr2 = [4, 5, 6];
      // 设置arr2使用concat方法合并数组时是否展开
      arr2[Symbol.isConcatSpreadable] = false;
      console.log(arr.concat(arr2));//[1, 2, 3, Array(3)]
      
    </script>
  </body>
</html>
